-
Notifications
You must be signed in to change notification settings - Fork 1.6k
✨ alpha(update): add --squash, --preserve-path, --output-branch for PR-friendly upgrades #5002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ alpha(update): add --squash, --preserve-path, --output-branch for PR-friendly upgrades #5002
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
5e5b396
to
e647ab5
Compare
88cb831
to
d986484
Compare
…friendly upgrades This change makes `kubebuilder alpha update` produce a PR-ready branch and a single squashed commit when requested, improving automation and review UX. Key changes ----------- • New `--squash` flag: - Snapshots the exact tree of the temporary merge branch into ONE commit on a stable branch: `kubebuilder-alpha-update-to-<to-version>`. - Intended for opening/refreshing idempotent PRs. - Gracefully handles "no changes" (git commit exits 1 → treated as no-op). • New `--preserve-path` (repeatable): - When squashing, restore given paths from the base branch (e.g. `.github/workflows`) so CI/config files are kept as-is on the PR branch. • New `--output-branch`: - Overrides the default PR branch name created by `--squash`. • Commit message used by `--squash`: - `[kubebuilder-automated-update]: update scaffold from <from> to <to>; (squashed 3-way merge)` • Behavior/ergonomics: - Without `--force`: stops on conflicts on the temporary merge branch. - With `--force`: commits conflict markers on the merge branch (automation-friendly). - After merge, still best-effort run: `make manifests generate fmt vet lint-fix`. Defaults / Compatibility ------------------------ - `--squash` is off by default (no behavior change unless opted-in). - `--from-branch` defaults to `main`. - `--preserve-path` is empty by default (no restores). - Safe to run on projects scaffolded with v4.5.0+ (uses `alpha generate`). Motivation ---------- Make upgrades PR-centric and automation-ready by producing a deterministic, reviewable branch and a single squashed commit that mirrors the merge result. Assisted-by: ChatGPT (OpenAI) Co-authored-by: Vitor Floriano <[email protected]>
d986484
to
0d40b9c
Compare
- **With `--force`**: the merge is committed (on `tmp-merge-*`) and contains the markers. | ||
- **With `--force`**: the merge is committed (on `tmp-merge-*`, or on the output branch if using `--squash`) and contains the markers. | ||
|
||
## Commit message used in `--squash` mode | ||
|
||
> [kubebuilder-automated-update]: update scaffold from <from> to <to>; (squashed 3-way merge) | ||
|
||
<aside class="note warning"> | ||
<h1>You might need to upgrade your project first</h1> | ||
|
||
This command uses `kubebuilder alpha generate` under the hood. | ||
We support projects created with <strong>v4.5.0+</strong>. | ||
If yours is older, first run `kubebuilder alpha generate` once to modernize the scaffold. | ||
After that, you can use `kubebuilder alpha update` for future upgrades. | ||
|
||
</aside> | ||
|
||
<aside class="note"> | ||
<h1>CLI Version Tracking</h1> | ||
|
||
Projects created with **Kubebuilder v4.6.0+** include `cliVersion` in the `PROJECT` file. | ||
We use that value to pick the correct CLI for re-scaffolding. | ||
|
||
</aside> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm The flags seem to incorporate the related steps in the workflow accordingly. We'll probably need to merge the changes and test it in a new workflow to be sure, though. |
@vitorfloriano: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
5e490bd
into
kubernetes-sigs:master
Thank you a lot for the review |
This change makes
kubebuilder alpha update
produce a PR-ready branch and a single squashed commit when requested, improving automation and review UX.Key changes
• New
--squash
flag:kubebuilder-alpha-update-to-<to-version>
.• New
--preserve-path
(repeatable):.github/workflows
) so CI/config files are kept as-is on the PR branch.• New
--output-branch
:--squash
.• Commit message used by
--squash
:[kubebuilder-automated-update]: update scaffold from <from> to <to>; (squashed 3-way merge)
• Behavior/ergonomics:
--force
: stops on conflicts on the temporary merge branch.--force
: commits conflict markers on the merge branch (automation-friendly).make manifests generate fmt vet lint-fix
.Defaults / Compatibility
--squash
is off by default (no behavior change unless opted-in).--from-branch
defaults tomain
.--preserve-path
is empty by default (no restores).alpha generate
).Motivation
Make upgrades PR-centric and automation-ready by producing a deterministic, reviewable branch and a single squashed commit that mirrors the merge result.
Assisted-by: ChatGPT (OpenAI)